# Copyright 2016, 2017 Peter Dimov
# Copyright 2017-2019 Kohei Takahashi
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)

language: cpp

sudo: false

cache: ccache

os:
  - linux
  - osx

env:
  matrix:
    - BOGUS_JOB=true

matrix:

  exclude:
    - env: BOGUS_JOB=true

  include:
    - os: linux
      dist: trusty
      env: TOOLSET=gcc-4.4 CXXSTD=98,0x
      addons:
        apt:
          packages:
            - g++-4.4
          sources:
            - ubuntu-toolchain-r-test

    #- os: linux
    #  dist: trusty
    #  env: TOOLSET=gcc-4.5 CXXSTD=03,0x
    #  addons:
    #    apt:
    #      packages:
    #        - g++-4.5
    #      sources:
    #        - ubuntu-toolchain-r-test

    - os: linux
      dist: trusty
      env: TOOLSET=gcc-4.6 CXXSTD=03,0x
      addons:
        apt:
          packages:
            - g++-4.6
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-4.7 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.7
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-4.8 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-4.8 CXXSTD=1y
      addons:
        apt:
          packages:
            - g++-4.8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-4.9 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.9
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-4.9 CXXSTD=14
      addons:
        apt:
          packages:
            - g++-4.9
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-5 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-5
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-5 CXXSTD=14,17
      addons:
        apt:
          packages:
            - g++-5
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-6 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-6
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-6 CXXSTD=14,17
      addons:
        apt:
          packages:
            - g++-6
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-7 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-7
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-7 CXXSTD=14,17
      addons:
        apt:
          packages:
            - g++-7
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-8 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-8 CXXSTD=14,17
      addons:
        apt:
          packages:
            - g++-8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-8 CXXSTD=2a
      addons:
        apt:
          packages:
            - g++-8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-9 CXXSTD=03,11,14 SANITIZED
      addons:
        apt:
          packages:
            - g++-9
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=gcc-9 CXXSTD=17,2a SANITIZED
      addons:
        apt:
          packages:
            - g++-9
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.5 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.5

    # Disable due to: error: debug information for auto is not yet supported
    #- os: linux
    #  dist: xenial
    #  env: TOOLSET=clang-3.5 CXXSTD=14,1z
    #  addons:
    #    apt:
    #      packages:
    #        - clang-3.5

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.6 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.6

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.6 CXXSTD=14,1z
      addons:
        apt:
          packages:
            - clang-3.6

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.7 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.7

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.7 CXXSTD=14,1z
      addons:
        apt:
          packages:
            - clang-3.7

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.8 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.8

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.8 CXXSTD=14,1z
      addons:
        apt:
          packages:
            - clang-3.8

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.9 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.9

    - os: linux
      dist: xenial
      env: TOOLSET=clang-3.9 CXXSTD=14,1z
      addons:
        apt:
          packages:
            - clang-3.9

    - os: linux
      dist: xenial
      env: TOOLSET=clang-4.0 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-4.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-4.0 CXXSTD=14,1z
      addons:
        apt:
          packages:
            - clang-4.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-5.0 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-5.0
          sources:
            - llvm-toolchain-xenial-5.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-5.0 CXXSTD=14,17
      addons:
        apt:
          packages:
            - clang-5.0
          sources:
            - llvm-toolchain-xenial-5.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-5.0 CXXSTD=2a
      addons:
        apt:
          packages:
            - clang-5.0
          sources:
            - llvm-toolchain-xenial-5.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-6.0 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-6.0
          sources:
            - llvm-toolchain-xenial-6.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-6.0 CXXSTD=14,17
      addons:
        apt:
          packages:
            - clang-6.0
          sources:
            - llvm-toolchain-xenial-6.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-6.0 CXXSTD=2a
      addons:
        apt:
          packages:
            - clang-6.0
          sources:
            - llvm-toolchain-xenial-6.0

    - os: linux
      dist: xenial
      env: TOOLSET=clang-7 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-7
          sources:
            - llvm-toolchain-xenial-7

    - os: linux
      dist: xenial
      env: TOOLSET=clang-7 CXXSTD=14,17
      addons:
        apt:
          packages:
            - clang-7
          sources:
            - llvm-toolchain-xenial-7

    - os: linux
      dist: xenial
      env: TOOLSET=clang-7 CXXSTD=2a
      addons:
        apt:
          packages:
            - clang-7
          sources:
            - llvm-toolchain-xenial-7

    - os: linux
      dist: xenial
      env: TOOLSET=clang-8 CXXSTD=03,11,14
      addons:
        apt:
          packages:
            - clang-8

    - os: linux
      dist: xenial
      env: TOOLSET=clang-8 CXXSTD=17,2a
      addons:
        apt:
          packages:
            - clang-8

    - os: linux
      dist: bionic
      env: TOOLSET=clang-9 CXXSTD=03,11,14 SANITIZED
      addons:
        apt:
          packages:
            - clang-9

    - os: linux
      dist: bionic
      env: TOOLSET=clang-9 CXXSTD=17,2a SANITIZED
      addons:
        apt:
          packages:
            - clang-9

    - os: osx
      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11

    - os: osx
      env: TOOLSET=clang COMPILER=clang++ CXXSTD=14,1z

install:
  - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
  - cd ..
  - git clone --depth 1 -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
  - cd boost-root

  - git submodule init libs/algorithm
  - git submodule init libs/any
  - git submodule init libs/array
  - git submodule init libs/assert
  - git submodule init libs/assign
  - git submodule init libs/atomic
  - git submodule init libs/bind
  - git submodule init libs/chrono
  - git submodule init libs/circular_buffer
  - git submodule init libs/concept_check
  - git submodule init libs/config
  - git submodule init libs/container
  - git submodule init libs/container_hash
  - git submodule init libs/conversion
  - git submodule init libs/core
  - git submodule init libs/date_time
  - git submodule init libs/detail
  - git submodule init libs/endian
  - git submodule init libs/exception
  - git submodule init libs/filesystem
  - git submodule init libs/foreach
  - git submodule init libs/format
  - git submodule init libs/function
  - git submodule init libs/function_types
  - git submodule init libs/functional
  - git submodule init libs/fusion
  - git submodule init libs/integer
  - git submodule init libs/intrusive
  - git submodule init libs/io
  - git submodule init libs/iostreams
  - git submodule init libs/iterator
  - git submodule init libs/lambda
  - git submodule init libs/lexical_cast
  - git submodule init libs/locale
  - git submodule init libs/log
  - git submodule init libs/math
  - git submodule init libs/move
  - git submodule init libs/mp11
  - git submodule init libs/mpl
  - git submodule init libs/multi_index
  - git submodule init libs/numeric/conversion
  - git submodule init libs/optional
  - git submodule init libs/parameter
  - git submodule init libs/pool
  - git submodule init libs/predef
  - git submodule init libs/preprocessor
  - git submodule init libs/property_tree
  - git submodule init libs/proto
  - git submodule init libs/ptr_container
  - git submodule init libs/python
  - git submodule init libs/random
  - git submodule init libs/range
  - git submodule init libs/ratio
  - git submodule init libs/rational
  - git submodule init libs/regex
  - git submodule init libs/serialization
  - git submodule init libs/signals2
  - git submodule init libs/smart_ptr
  - git submodule init libs/spirit
  - git submodule init libs/static_assert
  - git submodule init libs/system
  - git submodule init libs/thread
  - git submodule init libs/throw_exception
  - git submodule init libs/tokenizer
  - git submodule init libs/tti
  - git submodule init libs/tuple
  - git submodule init libs/type_index
  - git submodule init libs/type_traits
  - git submodule init libs/typeof
  - git submodule init libs/unordered
  - git submodule init libs/utility
  - git submodule init libs/variant
  - git submodule init libs/winapi
  - git submodule init libs/xpressive

  - git submodule init libs/headers tools/boost_install tools/build
  - git submodule update --jobs 8

  - rm -rf libs/phoenix
  - mv $TRAVIS_BUILD_DIR libs/phoenix
  - ln -s $(pwd)/libs/phoenix $TRAVIS_BUILD_DIR

  - ./bootstrap.sh
  - ./b2 headers

  - |
    if [ $TRAVIS_OS_NAME = osx ]; then
      export PATH="/usr/local/opt/ccache/libexec:$PATH"
      brew install ccache
    fi
  - |-
    echo "using ${TOOLSET%%-*} : ${TOOLSET#*-} : ccache `echo $TOOLSET | sed 's/clang/clang++/;s/gcc/g++/'` ;" > ~/user-config.jam

script:
  - ./b2 libs/phoenix/test toolset=$TOOLSET cxxstd=$CXXSTD
      ${SANITIZED+cxxflags=-fsanitize=address,undefined}
      ${SANITIZED+'linkflags=-fsanitize=address,undefined -fuse-ld=gold'}
